
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="fr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Notation des commerces de Mons >> Stats</title>
        <link rel="stylesheet" href="./mystyle.css" type="text/css" media="screen" />
    </head>
    <body>
        <center>
            <?php
                    /*
                     * To change this template, choose Tools | Templates
                     * and open the template in the editor.
                     */
            //include 'myheader.php';

            echo "<div id='colonne1' align='center' class='colonnem'>";
            include 'connect_db.php';
            $sql="SELECT COUNT(idusers) AS 'nbr' FROM users_site;";
            $result=mysql_query($sql);

            echo "<br>";
            while($tableau=mysql_fetch_array($result,MYSQL_ASSOC)){
                echo "Nombre d'utilisateurs: ".$tableau['nbr'];
            }
            echo "</br>";

            echo "<br>";
            $sql="SELECT COUNT(idratings) AS 'nbr' FROM ratings;";
            $result=mysql_query($sql);
            while($tableau=mysql_fetch_array($result,MYSQL_ASSOC)){
                echo "Nombre de ratings: ".$tableau['nbr'];
            }
            $sql="SELECT SUM(NU) as 'mysum'
                    FROM
                    (
                        SELECT COUNT(users_idusers)AS 'NU', NBR
                        FROM
                        (
                            SELECT users_idusers,COUNT(idratings) AS 'NBR'
                            FROM ratings
                            GROUP BY users_idusers
                            ORDER BY NBR
                        ) AS REQ
                        GROUP BY NBR
                    )as REQ1
                    WHERE NBR>=6;";
            $result=mysql_query($sql);

            echo "<br>";
            while($tableau=mysql_fetch_array($result,MYSQL_ASSOC)){
                echo "Nombre d'utilisateurs (>=6 votes): ".$tableau['mysum'];
            }
            echo "</br>";
            echo "</br>";

            $sql="SELECT COUNT(users_idusers)AS 'NU', NBR
                    FROM
                    (
                        SELECT users_idusers,COUNT(idratings) AS 'NBR'
                        FROM ratings
                        GROUP BY users_idusers
                        ORDER BY NBR
                    ) AS REQ
                    GROUP BY NBR
                    ORDER BY NBR";
            $result=mysql_query($sql);
            echo '<TABLE BORDER=0>';
            echo '<TR><TD><b>Nombre de notes</b></TD><TD><b>Nombre d utilisateurs</b></TD></TR>';
            while($tableau=mysql_fetch_array($result,MYSQL_ASSOC)){
                echo "<TR>";
                echo "<TD>".$tableau['NBR']."</TD>";
                echo "<TD>".$tableau['NU']."</TD>";
                echo "</TR>";
            }
            echo "</TABLE>";


            echo "</div>";
            mysql_close($link);
            ?>
        </center>
    </body>
</html>